# Metview Macro

synop = read("synop.bufr")

wind_speed_10m_descriptor     = 11012
wind_direction_10m_descriptor = 11011
wind_speed_max_threshold      = 50 # m/s


wind_speed_and_direction = obsfilter(
    output           : "polar_vector",
    parameter        : [wind_speed_10m_descriptor, wind_direction_10m_descriptor],
    custom_filter    : "range",
    custom_parameter : wind_speed_10m_descriptor,
    custom_values    : [0,wind_speed_max_threshold],
    data             : synop
    )

coloured_wind_arrows = mwind(
    legend                                : "on",
    wind_advanced_method                  : "on",
    wind_advanced_colour_max_level_colour : "red",
    wind_advanced_colour_min_level_colour : "blue",
    wind_advanced_colour_direction        : "clockwise",
    wind_arrow_head_ratio                 : 0.7,
    wind_arrow_thickness                  : 2
    )

grey_land_and_sea_shade = mcoast(
    map_coastline_land_shade        : "on",
    map_coastline_land_shade_colour : "RGB(0.72,0.72,0.72)",
    map_coastline_sea_shade         : "on",
    map_coastline_sea_shade_colour  : "RGB(0.6,0.6,0.6)"
    )

area_view = geoview(
    map_area_definition : "corners",
    area                : [26.23,-25.45,74.83,45.69],
    coastlines          : grey_land_and_sea_shade
    )


plot(area_view, wind_speed_and_direction, coloured_wind_arrows)
